﻿<Framework:BasePage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Framework="clr-namespace:JustinAngel.UnitedNationsNews.Framework" xmlns:System_Windows_Controls="clr-namespace:System.Windows.Controls" xmlns:SliderApp="clr-namespace:SliderApp" 
    xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:smf="clr-namespace:Microsoft.SilverlightMediaFramework.Core;assembly=Microsoft.SilverlightMediaFramework.Core.Phone"
	xmlns:Custom="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
	xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7" 
    xmlns:smf_converters="clr-namespace:Microsoft.SilverlightMediaFramework.Utilities.Converters;assembly=Microsoft.SilverlightMediaFramework.Utilities.Phone" xmlns:smf_accesscontrols="clr-namespace:Microsoft.SilverlightMediaFramework.Core.Accessibility.Controls;assembly=Microsoft.SilverlightMediaFramework.Core.Phone" xmlns:Unsupported="clr-namespace:Microsoft.Unsupported" x:Class="JustinAngel.UnitedNationsNews.Pages.Video.VideoPage"
    Foreground="Black"
    SupportedOrientations="Landscape" Orientation="Landscape"
    mc:Ignorable="d" d:DesignHeight="480" d:DesignWidth="800"
    shell:SystemTray.IsVisible="False" d:DataContext="{d:DesignData /SampleData/VideoAndRadioViewModelSampleData.xaml}">
	<Framework:BasePage.FontFamily>
		<StaticResource ResourceKey="PhoneFontFamilyNormal"/>
	</Framework:BasePage.FontFamily>
	<Framework:BasePage.FontSize>
		<StaticResource ResourceKey="PhoneFontSizeNormal"/>
	</Framework:BasePage.FontSize>
	<Framework:BasePage.ViewModel>
		<Binding Path="VideoAndRadioViewModel" Source="{StaticResource ViewModelLocator}"/>
	</Framework:BasePage.ViewModel>

	<Grid x:Name="LayoutRoot" Background="Black">
		<VisualStateManager.VisualStateGroups>
			<VisualStateGroup x:Name="MediaLoadingStates">
				<VisualStateGroup.Transitions>
					<VisualTransition From="IsMediaLoading" GeneratedDuration="0:0:0.7" To="NotIsMediaLoading"/>
					<VisualTransition From="NotIsMediaLoading" GeneratedDuration="0:0:0.7" To="IsMediaLoading"/>
				</VisualStateGroup.Transitions>
				<VisualState x:Name="IsMediaLoading">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="loadingProgressBar">
							<DiscreteObjectKeyFrame KeyTime="0">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="loadingProgressBar" d:IsOptimized="True"/>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(ProgressBar.IsIndeterminate)" Storyboard.TargetName="loadingProgressBar">
							<DiscreteObjectKeyFrame KeyTime="0">
								<DiscreteObjectKeyFrame.Value>
									<System:Boolean>True</System:Boolean>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="loadingText" d:IsOptimized="True"/>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="loadingText">
							<DiscreteObjectKeyFrame KeyTime="0">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="NotIsMediaLoading">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(ProgressBar.IsIndeterminate)" Storyboard.TargetName="loadingProgressBar">
							<DiscreteObjectKeyFrame KeyTime="0">
								<DiscreteObjectKeyFrame.Value>
									<System:Boolean>False</System:Boolean>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="loadingProgressBar">
							<DiscreteObjectKeyFrame KeyTime="0">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="loadingProgressBar" d:IsOptimized="True"/>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="loadingText">
							<DiscreteObjectKeyFrame KeyTime="0">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="loadingText" d:IsOptimized="True"/>
					</Storyboard>
				</VisualState>
			</VisualStateGroup>
			<VisualStateGroup x:Name="PosterVisiblityStates">
				<VisualState x:Name="IsPosterVisible">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="poster">
							<DiscreteObjectKeyFrame KeyTime="0">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="changePosterImageButton">
							<DiscreteObjectKeyFrame KeyTime="0">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="NotIsPosterVisible"/>
			</VisualStateGroup>
		</VisualStateManager.VisualStateGroups>
		<Image x:Name="poster" Source="{Binding Poster}" HorizontalAlignment="Center" Visibility="Collapsed" Stretch="None"/>
		<smf:SMFPlayer x:Name="smfPlayer" Playlist="{Binding Playlist}" CaptionsVisibility="Disabled" ChaptersVisibility="Disabled" PlaylistVisibility="Disabled" VolumeLevel="1" IsControlStripVisible="{Binding IsMediaBarVisible, Mode=TwoWay}" Background="{StaticResource PhoneBackgroundBrush}" Style="{StaticResource SMFPlayerStyle1}" >
			<Custom:Interaction.Triggers>
				<Custom:EventTrigger EventName="PlayStateChanged">
					<GalaSoft_MvvmLight_Command:EventToCommand PassEventArgsToCommand="True" Command="{Binding PlayStateChangedCommand, Mode=OneWay}"/>
				</Custom:EventTrigger>
				<Custom:EventTrigger EventName="MediaEnded">
					<GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding MediaEnded}"/>
				</Custom:EventTrigger>
			</Custom:Interaction.Triggers>
		</smf:SMFPlayer>

		<ProgressBar x:Name="loadingProgressBar" Height="8" Style="{StaticResource PerformanceProgressBar}" VerticalAlignment="Top" Margin="0,159,0,0" IsIndeterminate="True"/>
		<TextBlock Visibility="Visible" Opacity="1" x:Name="loadingText" Height="27" Margin="0,128,0,0" TextWrapping="Wrap" Text="Loading..." VerticalAlignment="Top" Foreground="White" FontSize="{StaticResource PhoneFontSizeSmall}" HorizontalAlignment="Center"/>
		<Button x:Name="changePosterImageButton" Unsupported:TiltEffect.IsTiltEnabled="True"  HorizontalAlignment="Right" VerticalAlignment="Top" Style="{StaticResource EmptyButtonStyle}" Visibility="Collapsed" Width="85" Height="85">
			<Custom:Interaction.Triggers>
				<Custom:EventTrigger EventName="Click">
					<GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding ChangePoster}"/>
				</Custom:EventTrigger>
			</Custom:Interaction.Triggers> 
		<Grid Margin="0,-11,-11,0"> 
				<Ellipse Fill="Black" HorizontalAlignment="Right" Height="55" Stroke="White" VerticalAlignment="Top" Width="55" StrokeThickness="3"/>
				<Image Margin="-1,-2,-1,0" Source="/Pages/Video/appbar.photo.png" Stretch="None"/>
			</Grid>
		</Button>
	</Grid>
 

</Framework:BasePage>
